package org.alis.smallcc.designpatterns.behavior.mediator;

import java.util.HashSet;
import java.util.Objects;
import java.util.Set;

/**
 * 传话铜 
 * @author: luochuan     
 * @date: 2020年12月28日 下午4:55:54   
 */
public class ChatMediator implements Mediator{

	private  Set<Colleague> set = new HashSet<>();
	
	@Override
	public void forward(Colleague from,Message message) {
		set.stream().filter(coll->Objects.nonNull(coll)&&!Objects.equals(coll, from)).forEach(action->action.handlerMessage(message));
	}

	@Override
	public void register(Colleague colleague) {
		this.set.add(colleague);
	}
	
	
}
